{extend name="personcentor/information"}

{block name="main"}
<div class="col-main">
	<div class="main-wrap">
		<!--{:dump($house)}-->
		{if condition="$house == null"}
			<div style="font-size:80px;color:#ccc">
				您还没有添加收藏呢！
			</div>
		{/if}
		{volist name="house" id="vo"}
		<div class="col-sm-6 col-md-4">
			<div class="thumbnail">
				<a class="lightbox" href="{:url('index/villa/detail',['id'=>$vo['id']])}">
					<img src="/uploads/housepic/{:str_replace('\','/',$vo.house_pic)}" alt="Park" style="width:200px;height:150px;">
				</a>
				<div class="caption">
					<h3 style="color:red;">￥{$vo['houseprice']}元/天</h3>
					<p>
						{$vo['house_name']}
						<button data-id="{$vo['id']}" class="btn collect">取消收藏</button>
					</p>
				</div>
			</div>
		</div>
		{/volist}
	</div>
</div>

<script>
    $(function(){
        $('.collect').click(function(){
            //获取当前房源信息id
            collect_id = $(this).attr('data-id');
            var t  = this;
			$.ajax({
				url: "/collect",
				type: "post",
				datatype: "json",
				data: {"id" : collect_id},
				success: function(data){
					if(data){
						alert('取消成功');
                        $(t).parents('.thumbnail').remove();
					}else{
						alert('取消失败，请重试!');
					}
				},
				error: function(data){
					alert('Ajax请求失败');
				}
			});
        });
    });
</script>

{/block}

